<?php
//$this->breadcrumbs=array(
//	'Autores'=>array('index'),
//	$model->id,
//);
//$this->menu=array(
//	array('label'=>'Elenco Autori', 'url'=>array('index')),
//	array('label'=>'Aggiungi Autore', 'url'=>array('create')),
//	array('label'=>'Aggiorna Autore', 'url'=>array('update', 'id'=>$model->id)),
//	array('label'=>'Elimina Autore', 'url'=>'#', 'linkOptions'=>array('submit'=>array('delete','id'=>$model->id),'confirm'=>'Are you sure you want to delete this item?')),
//	array('label'=>'Gestisci Autori', 'url'=>array('admin')),
//        array('label'=>'Gestisci Immagini', 'url'=>array('galleria/index', 'idAutore'=>$model->id)),        
//        array('label'=>'Gestisci Contatti', 'url'=>array('contatto/index', 'idAutore'=>$model->id)),
//);
?>
<div class="span-19" id="contentLeft">
    <div id="content">
        <div id="logo">
            <?php
            if ($model->idLogo > 0 && $model->Logo->FilesID > 0) {
                $fileInfo = FileInfos::model()->findByPk($model->Logo->FilesID);
                if ($fileInfo->FilesName != '') {
                    ?>
            <?php echo CHtml::image($fileInfo->FilesName, $model->Logo->alt); ?>
                    

                    <?php
                }
            }
            ?>
        </div>
        <div id="aforisma">            
            "<?php echo $model->aforisma; ?>"
        </div>

        <?php
        if ($model->Gallerie != null) {

            $this->beginWidget('ext.prettyPhoto.PrettyPhoto', array(
                'id' => 'pretty_photo',
                // prettyPhoto options
                'options' => array(
                    'opacity' => 0.60,
                    'modal' => true,
                ),
            ));

            foreach ($model->Gallerie as $gallery) {

                if ($gallery->Tipo->cod == "I") {
                    $images = $gallery->Immagini;
                    ?>
                    <div id="immagini">
                            
                        <ul>
                            <?php
                            foreach ($images as $image) {
                                ?>
                                <li class="immagine">
                                    <a href="<?php echo $image->files->FilesName; ?>" title="<?php echo $image->alt; ?>">
                                        <img src="<?php echo $image->files->Thumbnails; ?>" class="immagine" title="<?php echo $image->title; ?>" alt="<?php echo $image->title; ?>"/>
                                    </a>
                                </li>
                                <?php
                            }
                            ?>
                        </ul>

                    </div>
                    <?php
                }
                if ($gallery->Tipo->cod == "V") {
                    $videos = $gallery->Video;
                    ?>
                    <div id="videos">

                        <script type="text/javascript" charset="utf-8">
                            $(document).ready(function(){
                                $("#videothumbs li a img").each(
                                function(index)
                                {
                                    var link = $(this).attr("src");
                                    var imgThumbSrc = $.jYoutube(link);
                                    $(this).attr('src',imgThumbSrc);
                                }
                            );
                            });                                        
                                        
                        </script>
                        <ul id="videothumbs">
                            <?php
                            foreach ($videos as $video) {
                                if (isset($video)) {
                                    $title = "";
                                    $link = "";
                                    $descr = "";
                                    if (isset($video->title))
                                        $title = $video->title;
                                    if (isset($video->descr))
                                        $descr = $video->descr;
                                    if (isset($video->link))
                                        $link = $video->link;
                                }
                                ?>
                                <li>
                                    <a href="<?php echo $link; ?>" title="<?php echo $descr; ?>">
                                        <img src="<?php echo $link; ?>" alt="<?php echo $title; ?>" title="<?php echo $title; ?>" height="170px"/>
                                    </a>
                                </li>
                                <?php
                            }
                            ?>
                        </ul>


                    </div>
                    <?php
                }
                if ($gallery->Tipo->cod == "M") {
                    $music = $gallery->Musica;
                    ?>

                    <div id="player">
                        <?php
                        $files = "";
                        $titles = "";
                        $authors = "";

                        foreach ($music as $musica) {
                            if ($music->files->FilesName != null)
                                $files .= $music->files->FilesName . ",";
                            if ($music->title != null)
                                $titles .= $music->title . ",";

                            $authors .= $gallery->Autore->nome . ",";
                        }
                        $files = substr($files, 0, strlen($files) - 1);
                        $titles = substr($titles, 0, strlen($titles) - 1);
                        $authors = substr($authors, 0, strlen($authors) - 1);

                        $this->widget(
                                'AiiAudioPlayer', array(
                            'playerID' => 'mpl',
                            'singlePlayer' => true,
                            'mp3Folder' => $gallery->Path,
                            'trackOptions' => array(
                                'soundFile' => $files,
                                'titles' => $titles,
                                'artists' => $authors,
                                'flashPlayerOptions' => array('width' => 350)
                            ),
                        ));
                        ?>
                    </div>
                    <?php
                }
            }

            $this->endWidget('ext.prettyPhoto.PrettyPhoto');
        }
        ?>
    </div><!-- content -->
</div>
<div class="span-5 last" id="contentRight">
    <div id="banner">
        <?php echo CHtml::image($model->Banner->files->FilesName, $model->Banner->alt); ?>
    </div>
    <div id="sidebar">
        <div id="infobar">
            <ul>
                <li><a class="title" href="#">BIO</a>
                    <div id="biografia">
                        <?php echo $model->biografia; ?>
                    </div>
                </li>
                <li><a class="title" href="#">WEB</a>
                    <div id="web">
                        <?php
                        foreach ($model->Contatti as $contatto) {
                            if ($contatto->TipoContatto->cod == 'L') {
                                echo CHtml::link($contatto->title, $contatto->contacts);
                                echo "<br/>";
                            }
                        }
                        ?>

                    </div>
                </li>
                <li><a class="title" href="#">CONTATTI</a>
                    <div id="contatti">
                        <?php
                        foreach ($model->Contatti as $contatto) {
                            if ($contatto->TipoContatto->cod == 'E') {
                                echo CHtml::mailto($contatto->title, $contatto->contacts);
                                echo "<br/>";
                            }
                            if ($contatto->TipoContatto->cod == 'T') {
                                echo $contatto->contacts;
                                echo "<br/>";
                            }
                        }
                        ?>

                    </div>
                </li>
            </ul>
        </div>
    </div><!-- sidebar -->
</div>




<?php
////$this->widget('zii.widgets.CDetailView', array(
//	'data'=>$model,
//	'attributes'=>array(
//		'id',
//		'nome',
//		'biografia',
//		array(               
//                    'label'=>'Banner',
//                    'type'=>'raw',
//                    'value'=>CHtml::image(FileInfos::model()->getThumbPath($model->idBanner)),
//                    
//                ),                
//		array(               
//                    'label'=>'Logo',
//                    'type'=>'raw',
//                    'value'=>CHtml::image(FileInfos::model()->getThumbPath($model->idLogo)),
//                ),
//		
//                array(               
//                    'label'=>'Tipo Autore',
//                    'type'=>'raw',
//                    'value'=>CHtml::encode($model->TipoAutore->descr),
//                ),
//                array(               
//                        'label'=>'Categoria',
//                        'type'=>'raw',
//                        'value'=>CHtml::encode($model->Categoria->descr),
//                    ),
//		
//	),
//)); 
?>
